/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elaborate.h2x.transform.position.schema.state;

import juixb.schema.OptionalOperator;
import juixb.schema.SchemaNode;

/**
 *
 * @author lendle
 */
public class OptionalStateParser implements StateParser{

    public boolean isApplicable(SchemaNode schemaNode) {
        return schemaNode instanceof OptionalOperator;
    }

    public State parseState(StateParsers parsers, SchemaNode schemaNode) {
        DefaultPseudoStateImpl state=new DefaultPseudoStateImpl();
        state.setMin(0);
        State child=parsers.parseState(schemaNode);
        state.addChildState(child);
        state.setFirstSet(child.getFirstSet());
        state.setLastSet(child.getLastSet());
        return state;
    }
    
}
